package day9;

class FirstThread extends Thread {

    private int i;

    public void run(){
        for (; i < 11; i++) {
            System.out.println(getName() + " " + i);
        }
    }
}

class SecondThread implements Runnable {
    private int i;

    @Override
    public void run() {
        for (; i < 11; i++) {
            System.out.println(Thread.currentThread().getName() + " " + i);
        }
    }
}

public class Demo2 {

    public static void main(String[] args) {
        for (int i = 0; i < 11; i++) {
            System.out.println(Thread.currentThread().getName() + " " + i);
            if (i == 2) {
                Thread mt = new FirstThread();
                mt.setName("这是Thread的");
                SecondThread st = new SecondThread();
                mt.start();
                new Thread(st, "这是Runnable的").start();
            }
        }
    }
}
